﻿using Entity.WMS.DTO.WarehouseOtherIn;
using Entity.WMS.View.WarehouseOtherIn;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using Service.WMS;

namespace AnQinManagermentBackendAPI.Controller.WMS
{
    /// <summary>
    /// 其他入库表
    /// </summary>
    [Route("api/[controller]")]
    [ApiController]
    [Authorize]
    public class WarehouseOtherInController : ControllerBase
    {
        /**
         * 其他入库业务接口
         */
        private readonly WarehouseOtherInService _warehouseOtherInService;

        /**
         * 构造函数注入
         */
        public WarehouseOtherInController(WarehouseOtherInService warehouseOtherInService)
        {
            _warehouseOtherInService = warehouseOtherInService;
        }

        /// <summary>
        /// 获取其他入库列表
        /// </summary>
        /// <param name="warehouseOtherInSearch"></param>
        [HttpGet]
        [ProducesResponseType(typeof(WarehouseOtherInView), 200)]
        public async Task<IActionResult> GetWarehouseOtherInList([FromQuery] WarehouseOtherInSearchDTO warehouseOtherInSearchDTO)
        {
            var response = await _warehouseOtherInService.GetWarehouseOtherInList(warehouseOtherInSearchDTO);
            return StatusCode(response.Status, response);
        }

        /// <summary>
        /// 获取其他入库子单列表
        /// </summary>
        /// <param name="warehouseOtherInItemSearchDTO"></param>
        [HttpGet("item")]
        [ProducesResponseType(typeof(WarehouseOtherInItemView), 200)]
        public async Task<IActionResult> GetCodeRuleList([FromQuery] WarehouseOtherInItemSearchDTO warehouseOtherInItemSearchDTO)
        {
            var response = await _warehouseOtherInService.GetWarehouseOtherInItemList(warehouseOtherInItemSearchDTO);
            return StatusCode(response.Status, response);
        }

        /// <summary>
        /// 新增其他入库
        /// </summary>
        /// <param name="warehouseOtherInAdd"></param>
        [HttpPost]
        public async Task<IActionResult> AddWarehouseOtherIn([FromBody] WarehouseOtherInAddDTO warehouseOtherInAddDTO)
        {
            var response = await _warehouseOtherInService.AddWarehouseOtherIn(warehouseOtherInAddDTO);
            return StatusCode(response.Status, response);
        }

        /// <summary>
        /// 删除其他入库
        /// </summary>
        [HttpDelete]
        public async Task<IActionResult> DeleteWarehouseOtherIn([FromBody] string Id)
        {
            var response = await _warehouseOtherInService.DeleteWarehouseOtherIn(Id);
            return StatusCode(response.Status, response);
        }

        /// <summary>
        /// 审核通过其他入库
        /// </summary>
        [HttpPost("Pass")]
        public async Task<IActionResult> PassWarehouseOtherIn([FromBody] string Id)
        {
            var response = await _warehouseOtherInService.PassWarehouseOtherIn(Id);
            return StatusCode(response.Status, response);
        }

        /// <summary>
        /// 审核不通过其他入库
        /// </summary>
        [HttpPost("UnPass")]
        public async Task<IActionResult> UnPassWarehouseOtherIn([FromBody] string Id)
        {
            var response = await _warehouseOtherInService.UnPassWarehouseOtherIn(Id);
            return StatusCode(response.Status, response);
        }

        /// <summary>
        /// 审核通过其他入库
        /// </summary>
        [HttpPost("CancelPass")]
        public async Task<IActionResult> CancelWarehouseOtherIn([FromBody] string Id)
        {
            var response = await _warehouseOtherInService.CancelPassWarehouseOtherIn(Id);
            return StatusCode(response.Status, response);
        }
    }
}
